package zh.stu.StrategyPattern.PayDemo;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author：KoVaVo
 * @Date：2020-11-01 16:18
 * @Version：1.0.0
 * @Description：支付策略方式
 */
public class PayStrategy {

    public static final String ALI_PAY ="ALIPAY";

    public static final String WECHAT_PAY="WECHATPAY";

    public static final String DEFAULT_PAY=ALI_PAY;

    private static Map<String,Payment> strategy = new HashMap<String,Payment>();

    static {
        strategy.put(ALI_PAY,new AliPay());
        strategy.put(WECHAT_PAY,new WeChatPay());
        strategy.put(DEFAULT_PAY,new AliPay());
    }

    public static Payment get(String payKey){
        if(!strategy.containsKey(payKey)){
            return strategy.get(payKey);
        }
        return strategy.get(payKey);
    }
}
